package com.ep.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ep.common.utils.PageUtils;
import com.ep.modules.app.dao.AppTutoringMapper;
import com.ep.modules.app.entity.AppTutoring;
import com.ep.modules.app.entity.AppTutoringExample;
import com.ep.modules.app.service.AppTutoringService;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppTutoringServiceImpl implements AppTutoringService {
    @Autowired
    private AppTutoringMapper appTutoringMapper;

    public PageUtils queryPage(Map<String, Object> params) {
        String searchKey = (String)params.get("searchKey");
        Long searchUserId = (Long)params.get("searchUserId");
        AppTutoringExample example = new AppTutoringExample();
        AppTutoringExample.Criteria criteria = example.createCriteria();
        List<AppTutoring> list = appTutoringMapper.selectByExample(example);
        Page<AppTutoring> page = new Page<>();
        page.setRecords(list);
        return new PageUtils(page);
    }

    public AppTutoring getById(Long id) {
        return appTutoringMapper.selectByPrimaryKey(id.intValue());
    }

    public void save(AppTutoring entity) {
        appTutoringMapper.insert(entity);
    }

    public void update(AppTutoring entity) {
        appTutoringMapper.updateByPrimaryKeySelective(entity);
    }

    public void deleteBatch(Long[] ids) {
        for (Long id : ids) {
                appTutoringMapper.deleteByPrimaryKey(id.intValue());
        }
    }
}